package com.hgk.wanwan.mvpguanli.tarena.presenter;

import android.graphics.Bitmap;

import com.hgk.wanwan.mvpguanli.tarena.entity.LoginUser;
import com.hgk.wanwan.mvpguanli.tarena.listener.OnLoadCodeFinishListener;
import com.hgk.wanwan.mvpguanli.tarena.listener.OnLoginUserFinishListener;
import com.hgk.wanwan.mvpguanli.tarena.model.ILoginModel;
import com.hgk.wanwan.mvpguanli.tarena.model.ModelFactory;
import com.hgk.wanwan.mvpguanli.tarena.view.ILoginView;


public class LoginPresenterImpl implements ILoginPresenter{
	ILoginView view;
	ILoginModel model;
	
	public LoginPresenterImpl(ILoginView iLoginView){
		this.view = iLoginView;
		this.model = ModelFactory.getILoginModel();
	}
	
	@Override
	public void getLoadCode() {
		// TODO Auto-generated method stub
		model.getLoadCode(new OnLoadCodeFinishListener() {
			
			@Override
			public void OnLoadCodeFinish(Bitmap bitmap, String sessionId) {
				view.setLoadCode(bitmap, sessionId);
			}
		});
	}

	@Override
	public void getLogin(LoginUser loginUser) {
		
		
		model.doLogin(view.getloginUser(),new OnLoginUserFinishListener() {

			@Override
			public void onLoginUserSucess(String result) {
				// TODO Auto-generated method stub
				view.setSuccess();
			}

			@Override
			public void onLoginUserError(String result) {
				// TODO Auto-generated method stub
				view.setError(result);
			}
		});
	}
		
	
}
